package cheme.ProcessEditor.Parts.Streams.Tag;

import org.eclipse.draw2d.Label;
import org.eclipse.gef.EditPolicy;

import cheme.ProcessEditor.Figures.DecoratableFigure;
import cheme.ProcessEditor.Figures.TagOverallComponentFig;
import cheme.ProcessEditor.Policies.OverallStreamDescPolicy;
import cheme.ProcessEditor.Table.AbstractTableRowPart;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.OverallTagComponent;

public class PartOverallTagComponent extends AbstractTableRowPart
{
	@Override
	protected DecoratableFigure<TagOverallComponentFig> createFigure()
	{
//		TableRowFig header = new TableRowFig();
//		
//		header.add(new TitleFig("Label"));
//		header.add(new TitleFig("Quantity"));
//		header.add(new TitleFig("Units"));
//		header.add(new TitleFig("Material"));

		TagOverallComponentFig figure = new TagOverallComponentFig();
		figure.setToolTip(new Label("This is a description of the overall chemical stream."));
		
		DecoratableFigure<TagOverallComponentFig> content = new DecoratableFigure<TagOverallComponentFig>(figure);
		
//		TableHeaderDecoration<DecoratableFigure<TagOverallComponentFig>> overall = new TableHeaderDecoration<DecoratableFigure<TagOverallComponentFig>>();
//		overall.setHeader(header);
//		overall.setContentPane(content);
		
		return content;
	}
	
	@Override
	protected void createEditPolicies()
	{
		installEditPolicy(EditPolicy.COMPONENT_ROLE, new OverallStreamDescPolicy());
//		installEditPolicy(EditPolicy.LAYOUT_ROLE, new PolicyDummyLayout());
	}
	
	public OverallTagComponent getModel()
	{
		return (OverallTagComponent)super.getModel();
	}
	
	public DecoratableFigure<TagOverallComponentFig> getFigure()
	{
		return (DecoratableFigure<TagOverallComponentFig>)super.getFigure();
	}
	
	@Override
	public TagOverallComponentFig getContentPane()
	{
		return getFigure().getContentPane();
	}
	
//	@Override
//	protected void addAnnotationVisual(EditPart childEditPart, int index)
//	{
//		/*
//		 * IF I am decoratable and the child is a decoration
//		 */
//		
//		if(getFigure().getContentPane() instanceof IDecoratable)
//		{
//			((IDecoratable)getFigure().getContentPane()).add((IDecorator)((GraphicalEditPart)childEditPart).getFigure());
//		}
//	}
	
//	@Override
//	protected void removeAnnotationVisual(EditPart childEditPart)
//	{
//		/*
//		 * IF I am decoratable and the child is a decoration
//		 */
//		if(getFigure().getContentPane() instanceof IDecoratable)
//		{
//			((IDecoratable)getFigure().getContentPane()).remove((IDecorator)((GraphicalEditPart)childEditPart).getFigure());
//		}
//	}
}
